import React, { Component, Suspense } from "react";
import { Route, HashRouter as Router, Switch, Redirect } from "react-router-dom";
import routes from "./routes";
class Index extends Component {
  render() {
    return (
      <Suspense fallback={<div>loading....</div>}>
        <Router>
          <Switch>
            {routes.map((route) => {
              return (
                <Route
                  path={route.path}
                  exact={route.exact}
                  key={route.path}
                  render={(props) => {
                    return (
                      <route.component
                        {...props}
                        routes={route.routes}
                      ></route.component>
                    );
                  }}
                ></Route>
              );
            })}
           <Redirect to="/404"></Redirect>
          </Switch>
        </Router>
      </Suspense>
    );
  }
}

export default Index;
